/*
 * @Author: your name
 * @Date: 2020-10-12 20:51:37
 * @LastEditTime: 2020-10-20 03:17:56
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \longh_admin\src\api\sendManage.js
 */
import request from '@/utils/request'

const sendManageApi = {
  SystemMsgList: '/api/sysNotification/getPageList',//系统推送消息列表
  AddSystemMsg: '/api/sysNotification/release',//添加系统推送消息
  GetSystemMsgById: '/api/sysNotification/info', //根据主键获取系统推送消息
  DeleteSystemMsgs: '/api/sysNotification/delBatchIds' //根据主键集合批量删除系统推送消息
}

/**
 * 获取系统推送消息列表
 * @param {Object} parameter -{"keyword":"标题","isAse":"是否正序","current":"页码","size":"每页条数"}
 */
export function getPageList(parameter) {
  return request({
    url: sendManageApi.SystemMsgList,
    method: 'post',
    data: parameter
  })
}

/**
 * 根据主键获取系统推送消息
 * @param {string} msgId -消息主键Id
 */
export function getSystemMsgById(msgId) {
  return request({
    url: sendManageApi.GetSystemMsgById,
    method: 'post',
    data: {
      "id": msgId
    }
  })
}

/**
 * 发布系统推送消息
 * @param {Object} parameter 
 * -{"title":"标题","content":"内容"}
 */
export function addSystemMsg(parameter) {
  return request({
    url: sendManageApi.AddSystemMsg,
    method: 'post',
    data: parameter
  })
}

/**
 * 根据消息主键集合批量删除消息
 * @param {string[]} params 
 */
export function deleteBatchIds(params) {
  return request({
    url: sendManageApi.DeleteSystemMsgs,
    method: 'post',
    data: params
  })
}

// 查看开关状态
export function getPushStatus() {
  return request({
    url: '/api/sysConfig/getPushStatus',
    method: 'post',
    data: {
      paramKey: 'masterKeySwitch'
    }
  })
}

// 更改开关状态
export function updatePushStatus(data) {
  return request({
    url: '/api/sysConfig/updatePushStatus',
    method: 'post',
    data
  })
}